package hmis.pos.Controller;


import hmis.pos.Entity.RoomType;
import hmis.pos.Service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("roomType")
@CrossOrigin(origins={"http://localhost:3000"})
public class RoomTypeController {

    @Autowired
    private RoomTypeService roomTypeService;

    @RequestMapping("save")
    @ResponseBody
    public RoomType save(@RequestBody RoomType roomType){
        return roomTypeService.save(roomType);
    }

    @RequestMapping("delete")
    @ResponseBody
    public boolean delete(@RequestBody RoomType roomType){
        return roomTypeService.delete(roomType);
    }

    @RequestMapping("update")
    @ResponseBody
    public RoomType update(@RequestBody RoomType roomType){
        return roomTypeService.update(roomType);
    }

    @RequestMapping("findById")
    @ResponseBody
    public RoomType findById(@RequestParam String id){
        return roomTypeService.findById(id);
    }

    @RequestMapping("findAll")
    @ResponseBody
    public List<RoomType> findAll(){
        return roomTypeService.findAll();
    }

    @RequestMapping("findByType")
    @ResponseBody
    public RoomType findByType(@RequestParam String type){
        return roomTypeService.findByType(type);
    }
}
